<?php

/**
 * Foto form base class.
 *
 * @method Foto getObject() Returns the current form's model object
 *
 * @package    costabravasfr
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BaseFotoForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'          => new sfWidgetFormInputHidden(),
      'vivienda_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('ViviendasAlquileres'), 'add_empty' => false)),
      'orderfoto'   => new sfWidgetFormInputText(),
      'nombrefoto'  => new sfWidgetFormInputText(),
      'caption'     => new sfWidgetFormInputText(),
      'created_at'  => new sfWidgetFormDateTime(),
      'updated_at'  => new sfWidgetFormDateTime(),
      'slug'        => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id'          => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)),
      'vivienda_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('ViviendasAlquileres'))),
      'orderfoto'   => new sfValidatorInteger(array('required' => false)),
      'nombrefoto'  => new sfValidatorString(array('max_length' => 255)),
      'caption'     => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'created_at'  => new sfValidatorDateTime(),
      'updated_at'  => new sfValidatorDateTime(),
      'slug'        => new sfValidatorString(array('max_length' => 255, 'required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorDoctrineUnique(array('model' => 'Foto', 'column' => array('nombrefoto'))),
        new sfValidatorDoctrineUnique(array('model' => 'Foto', 'column' => array('slug'))),
      ))
    );

    $this->widgetSchema->setNameFormat('foto[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Foto';
  }

}
